import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;


public class Effect {

	public  int x, y;
	public  int w,h;
	public static int type;
	public int f;
	
	public int currFrame = 0;
	public int ROW = 5;
	
	public static final int KHOI = 0;
	public static final int MAU = 1;
	Image img;
	
	public Effect(int x1, int y1, int t){
		x = x1;
		y = y1;
		type = t;		
		
		try {
			switch (type) {
			case KHOI:
				img = Image.createImage("/bui.png");
				break;
			case MAU:
				img = Image.createImage("/mau0.png");
				break;
				
			default:
				break;
			}
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		w = img.getWidth();
		h = img.getHeight()/ROW;
	}
	
	public void update()
	{		
		
		f++;	
		switch (type) {
		case KHOI:
			if(f==5)
			{
				Cuop.effectsVec.removeElementAt(KHOI);
			}
			break;
		case MAU:
			if(f==20)
			{
				Cuop.effectsVec.removeElementAt(KHOI);
			}
			break;

		default:
			break;
		}
	}
	

	
	public void paint(Graphics g)
	{
		switch (type) {
		case KHOI:
			g.drawRegion(img, 0, h*f, w, h, 0, x, y, Graphics.VCENTER|Graphics.HCENTER);
			break;
		case MAU:
			g.drawImage(img, x, y,  Graphics.HCENTER|Graphics.VCENTER);
			break;

		default:
			break;
		}
	}
	
}
